import socket
import time
import _thread
import os
door_status = 2
HOST = '192.168.1.113'  
#os.chdir()
print(os.system("pwd"))

def main():

    ios = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    ios.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

    ios.bind((HOST, 8080))

    ios.listen(3)
    # ---------------------------------------------------------------#

    _thread.start_new_thread(ios_server, (ios,))



def ios_server(ios):
    global door_status
    ios_connection, ios_address = ios.accept()
    while True:
        data = ios_connection.recv(1024)
        print(data)
        print(data[0])
        if(data[0]=='1'):
            print("receive 1")
            os.system("./1.sh")
        if(data[0]=='2'):
            print("receive 2")
            os.system("./2.sh")
        if(data[0]=='3'):
            print("receive 3")
            os.system("./3.sh")

        #print(ios_address)

    ios_connection.close()
		#00 00 00 00


if __name__ == '__main__':
    main()
    while 1:
        pass
